/**
 * Created by 闲道人阿力 on 2016/10/18.
 */

function sendmail(email,subject,body,callback) {
    $.ajax({
        url:"/index.php?m=api&v=sendmail",
        method:"post",
        data:{
            email:email,
            subject:subject,
            body:body
        },
        dataType:"json",
        success:callback

    })
}

function sendmailaliyun(email,subject,body,callback) {
    $.ajax({
        url:"/index.php?m=api&v=sendmailaliyun",
        method:"post",
        data:{
            email:email,
            subject:subject,
            body:body
        },
        dataType:"json",
        success:callback

    })
}

function saveziduan(table,a,callback) {
    $.ajax({
        url:"/index.php?m=api&v=saveziduan&table="+table+"&"+a,
        method:"get",
        dataType:"json",
        success:callback
    })



}


function sendsms(mobile,param,callback) {
    $.ajax({
        url:"/index.php?m=api&v=sendsms&mobile="+mobile+"&param="+param,
        method:"get",
        dataType:"json",
        success:callback
    })



}


function checksms(mobile,param,callback) {
    $.ajax({
        url:"/index.php?m=api&v=checksms&mobile="+mobile+"&code="+param,
        method:"get",
        dataType:"json",
        success:callback
    })



}
function getcode(callback) {

    $.ajax({
        url:"/index.php?m=api&v=getcode&f=api",
        method:"get",
        success:callback
    })

}

function getuid() {
    $.ajax({
        url:"/index.php?m=api&v=getuid&f=api",
        method:"get",
        success:callback
    })
}

/**
 *
 * @param cid
 * @param page
 * @param count
 * @param sourceid 源HTML模版的父ID号
 * @param targetid 将生成的Html注入到哪个标签内(ID)
 * @param noresultcallback 全部完成后的回调函数,传入当前个数
 * @param cut 字符串截取
 */

function getnextpage(cid,page,count,sourceid,targetid,noresultcallback,cut) {



    $.ajax({
            url:"/index.php?m=api&v=getlists&cid="+cid+"&count="+count+"&page="+page,
            method:"get",

            dataType:"json",
            success:function (arrays) {
               // alert(JSON.stringify(arrays));

                $.each(arrays,function (e,data) {
                    var result = $("#"+sourceid).html();
                    $.each(data,function (a,b) {
                        for(var i in cut){
                            if(a==i){
                                var aaaaaa= "bbbbbbbb";
                                b=b.substring(0,cut[i]);
                            }
                        }
                        result =result.replace("{data."+a+"}",b);


                    })
                    $("#"+targetid).append(result);
                })

                noresultcallback(arrays.length);
            }

        })


}





